package com.xwh.week1;

import java.math.BigInteger;

public class Practice10 {
    public static void main(String[] args) {
        System.out.println(method(2000000));
    }

    public static String method(int length) {
        BigInteger sum = new BigInteger("0");

        for(int i = 2; i < length; ++i) {
            if (method2(i)) {
                Integer a = i;
                BigInteger i1 = new BigInteger(a.toString());
                BigInteger add = sum.add(i1);
                sum = add;
            }
        }

        return sum.toString();
    }

    public static boolean method2(int num) {
        int flag = 1;
        int j = (int)Math.sqrt((double)num);

        for(int i = 2; flag != 0 && i <= j; ++i) {
            flag = num % i;
        }

        return flag != 0;
    }
}
